//
// Created by mac on 1/24/22.
//
#include <iostream>
#include <vector>

using namespace std;


vector<vector<int>> generate(int numRows) {
    vector<vector<int>> res;
    for (int row = 0; row < numRows; ++row) {
        vector<int> oneRow;
        for (int col = 0; col <= row; ++col) {
            if(col==0 || col==row){
                oneRow.push_back(1);
            } else{
                vector<int> preRow = res[row-1];
                oneRow.push_back(preRow[col]+preRow[col-1]);
            }
        }
        res.push_back(oneRow);
    }
    return res;
}